<template>
    <view :class="showStr" @click="cancel">
      <view class="content">
        <view class="title">
          <image src="/static/icon/success.png"></image>
        </view>
        <view class="c1">
          <slot></slot>
        </view>
        <view class="btn" @click="okEvent">
          <text>{{ btnData }}</text>
        </view>
      </view>
  
    </view>
  </template>
  <script>
  export default {
    props: {
      show: { type: Boolean, default: false },
      tabBar: { type: Boolean, default: false },
      btn: { type: String, default: "知道了" }
    },
    data() {
      return {
        btnData: this.ok,
        showStr: this.show ? 'show' : 'hide',
      }
    },
    beforeMount() {
      this.btnData = this.btn;
    },
    watch: {
      btn: {
        handler(val) {
          this.btnData = val;
        },
        deep: true,
        immedaite: true
      },
      show: {
        handler(val) {
          if(!this.tabBar){
             if (val) {
              uni.hideTabBar();
            } else {
              uni.showTabBar()
            }
          }
          this.setShow(val);
        },
        deep: true,
        immedaite: true
      }
    },
    methods: {
      okEvent() {
        this.setShow(false);
        this.$emit("ok");
      },
      setShow(val) {
        this.showStr = val ? 'show' : 'hide';
      },
      cancel(){
        this.$emit("cancel");
      }
    }
  }
  </script>
  
  <style scoped lang="scss">
  @mixin main() {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    z-index: 999;
    background: rgba(0, 0, 0, 0.4);
  }
  .content {
    
    border-radius: 26px;
    width: 518rpx;
    height: 568rpx;
    padding: 20rpx;
    position: relative;
	background-color: #ffffff;
    .title {
		
      display: flex;
      justify-content: center;
       image{
        width: 146rpx;
        height: 146rpx;
       }
    }
    .c1 {
		margin-top: 56rpx;
     font-family: PingFangSC, PingFang SC;
     font-weight: 400;
     font-size: 32rpx;
     color: #383838;
     line-height: 44rpx;
     text-align: justify;
     font-style: normal;
    }
  }
  .hide {
    @include main();
    display: none;
  }
  .show {
    @include main();
    display: flex;
  }
  .btn {
	  margin-top: 68rpx;
   width: 368rpx;
   height: 86rpx;
   background: #252F62;
   border-radius: 44rpx;
   
    font-size: 32rpx;
    font-family: PingFangSC, PingFangSC-Semibold;
    font-weight: 600;
    text-align: center;
    color: #ffffff;
    line-height: 22px;
    letter-spacing: 0.8px;
    display: flex;
    justify-content: center;
    align-items: center;
    text {
      display: block;
    }
  }
  </style>